package com.kejizhentan.springboot2thymeleaf.controller;

import com.kejizhentan.springboot2thymeleaf.bean.User;
import com.kejizhentan.springboot2thymeleaf.exception.BasicTableNoVisitException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collector;

@Controller
public class TableController {
    @GetMapping("/basic_table")
    public String basic_table(){
        if(1== 1){
            throw new BasicTableNoVisitException();
        }
        return "tables/basic_table";
    }
    @GetMapping("/dynamic_table")
    public String dynamic_table(Model model){
        List<User> users = Arrays.asList(new User("zhagnsan","123544"),new User("lisi","656565"),new User("wangwu","9959"));
        model.addAttribute("users",users);
        return "tables/dynamic_table";
    }
    @GetMapping("/editable_table")
    public String editable_table(){
        return "tables/editable_table";
    }
    @GetMapping("/pricing_table")
    public String pricing_table(){
        return "tables/pricing_table";
    }
    @GetMapping("/responsive_table")
    public String responsive_table(){
        return "tables/responsive_table";
    }
}
